<template>
    <div class="header">
        <el-menu
                :default-active="toString(1)"
                class="el-menu-demo"
                mode="horizontal"
                background-color="#FFFFFF"
                text-color="#000000"
                active-text-color="#2ECCFA"
                :router="true">
            <el-menu-item index="/" id="log">笔记云</el-menu-item>

            <el-menu-item index="/index" class="biger">
                <i class="el-icon-house"></i> 首页
            </el-menu-item>

            <el-menu-item index="/index/login" class="biger">
                <i class="el-icon-edit"></i> 写文章
            </el-menu-item>

            <el-input placeholder="请输入内容" v-model="search" clearable>
                <el-button slot="append" icon="el-icon-search" @click="SearchArticle"></el-button>
            </el-input>

        </el-menu>
    </div>
</template>

<script>
    export default {
        name: "Header",
        data() {
            return {
                search: ""
            }
        },
        methods: {
            SearchArticle(){
                if(this.search===''){
                    this.$message.warning("搜索内容不能为空！");
                }else {
                    this.$router.push({name: 'Search', params: {search: this.search}});
                }
            }
        }
    }
</script>

<style scoped>
    .header {
        margin-left: 10%;
        width: 80%;
    }

    #log {
        font-weight: bold;
        font-size: 30px;
    }

    .biger {
        font-size: 17px;
    }

    .el-input {
        width: 20%;
        margin-right: 0;
    }

    a {
        text-decoration: none;
    }

    .router-link-active {
        text-decoration: none;
    }

</style>